package butines.core.game;

public class Timer {

	private static final int   TIMER_RESOLUTION = 1000000000;
    private static final float INVERSE_TIMER_RESOLUTION = 1f / TIMER_RESOLUTION;
    
    private long startTime;
    private long lastTime;     
    private long frameTime;
    private float deltaTime;  
    
    public Timer() {
    }

    public long getCurrentTime() {
        return System.nanoTime();
    }

    public long getTimeResolution() {
        return TIMER_RESOLUTION;
    }

    public float getDeltaTime() {
        return deltaTime;
    }

    public long getStartTime() {
		return startTime;
	}

	public long getFrameTime() {
		return frameTime;
	}

	public void tick() {
    	frameTime = getCurrentTime();
        deltaTime = (frameTime - lastTime) * INVERSE_TIMER_RESOLUTION;
        lastTime = frameTime;
    }
	
    public void start() {
    	frameTime = getCurrentTime();
    	startTime = frameTime;
        lastTime  = frameTime;
    }
    
}